package wangxu

import "fmt"

var Wangxu = &wangxu{
	Passport: &wangxuPassport{
		uri: "http://localhost:5236/api",
	},
	Payment: &wangxuPayment{
		uri: "http://localhost:5234/api",
	},
	Vip: &wangxuVip{
		uri: "http://localhost:5235/api",
	},
}

type wangxu struct {
	Passport *wangxuPassport
	Payment  *wangxuPayment
	Vip      *wangxuVip

	Production bool // 生产环境
}

func (r *wangxu) SetProd() *wangxu {
	r.Production = true

	return r
}

func (r *wangxu) GetUrl(region string, uris ...string) string {
	switch region {
	case "hk":
		region = "gw"
	case "sz":
		region = "aw"
	default:
	}

	slug := "dev"
	if r.Production {
		slug = ""
	}

	uri := ""
	if len(uris) > 0 {
		for _, item := range uris {
			uri += item
		}
	}

	result := fmt.Sprintf("https://%s%s.aoscdn.com%s", slug, region, uri)

	return result
}
